#include "SwitchNode.h"

#include "Output/Console.h"
#include "ScriptCompiler/AST/CaseNode.h"
#include "ScriptCompiler/AST/SentenceBlockNode.h"
#include "ScriptCompiler/Token/Token.h"
#include "ExpressionNode.h"

void CSwitchNode::DebugPrint(int32_t InDepth)
{
    //print depth
    for (int32_t i = 0; i < InDepth; i++)
    {
        WH::Print(U"\t");
    }

    WH::Print(U"switch(");
    Value->DebugPrint(0);
    WH::Print(U")\n");

    //print depth
    for (int32_t i = 0; i < InDepth; i++)
    {
        WH::Print(U"\t");
    }

    WH::Print(U"{\n");

    for (auto& Case : Cases)
    {
        Case->DebugPrint(InDepth + 1);
    }

    if (DefaultCase)
    {
        //print depth
        for (int32_t i = 0; i < InDepth + 1; i++)
        {
            WH::Print(U"\t");
        }

        WH::Print(U"default:\n");

        DefaultCase->DebugPrint(InDepth + 2);
    }

    //print depth
    for (int32_t i = 0; i < InDepth; i++)
    {
        WH::Print(U"\t");
    }

    WH::Print(U"}\n");
}

std::shared_ptr<CScriptToken> CSwitchNode::GetFirstToken()
{
    return Switch;
}
